/**
 * @file 
 * This file has displays BOINC project information via the MythTV interface
 * 
 * @author Kenneth Dixon
 * @version 0.2
 * 
 * Licence:
 * 
 * MythBOINC is a BOINC plugin for MythTV, it allows for BOINC Client management via the MythTV interface.
 * Copyright (C) 2008  Kenneth Dixon
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
#ifndef MYTHBOINC_H
#define MYTHBOINC_H

#include <mythtv/uitypes.h>
#include <mythtv/mythdialogs.h>


class MythBoinc : public MythThemedDialog
{
    
    
    Q_OBJECT
   
    
    public:
    
    
        /**
        * This constructor initialises display page
        */
        MythBoinc(MythMainWindow *parent, QString windowName, QString themeFilename, const char *name = 0);
        
        
        /**
        * This destructor tidies up
        */        
        ~MythBoinc();
        
        
    protected:
    
    
        void keyPressEvent(QKeyEvent*);
    
        
    private:
    
    
        /**
        * Holds the display tree  
        * 
        * @var root
        */
        UIManagedTreeListType *root;
        
        
        /**
        * Holds a tree for each host  
        * 
        * @var BoincClientHosts
        */       
        GenericTree *BoincClientHosts;
        
        
        /**
        * Hold the command path for boinc_cmd  
        * 
        * @var cmd
        */         
        string cmd;
        
        
        /**
        * Stores the raw results from boinc_cmd  
        * 
        * @var allResults
        */         
        vector<string> allResults;
        
        
        /**
        * Stores the refined results from the allResults vector
        * 
        * @var refinedResults
        */        
        vector<string> refinedResults;
 
        
//Attributes
/************************************************/
//Methods        
 
 
        /**
        * Converts an integer to a string
        * 
        * @param inInt - integer to be cast
        * @return - integer as a string 
        */         
        string IntToString(int);
        
        
        /**
        * Converts a string into a float
        * 
        * @param inString - string to be cast
        * @return - a floating pint number
        */         
        float StringToFloat(string);
        
        
        /**
        * Converts a float into a string
        * 
        * @param inFloat - float to be cast
        * @return - a number as a string
        */        
        string FloatToString(float);
        
        
        /**
        * Tests a specific client connection
        * 
        * @param ID - The client identifier
        * @return - true if connection established else false
        */        
        bool TestClientConnection(int);
        
        
        /**
        * Trigers the population of the tree + metadata
        * 
        * @param numOfClients - The number of clients to look for
        */         
        void GetHosts(int);
        
        
        /**
        * Extracts info per host for refinment to metadata
        * 
        * @param  ID - The client identifier
        */        
        void PopulateClientInfo(int);
        
        
        /**
        * Attaches a host + associated metadata to parent tree
        * 
        * @param ID - The client identifier
        * @return - A tree with host and its children attached
        */         
        GenericTree* AttachHost(int);
        
        
        /**
        * Attaches a project + associated metadata to parent tree
        * 
        * @param masterURL - URL to identify attached projects
        * @param ptr - pointer to the refinedResults vector, storing the metadata
        * @param ID - The client identifier
        * @return - A tree with project and its children attached
        */                
        GenericTree* AttachProject(string, int, int);
        
        
        /**
        * Attaches a work unit + associated metadata to parent tree
        * 
        * @param ptr - pointer to the refinedResults vector, storing the metadata
        * @param ID - The client identifier
        * @return - A tree with work unit attached
        */               
        GenericTree* AttachWorkUnit(int, int);
        
        
        /**
        * Updates the metadata associated with the selected leaf in the display tree
        *
        */          
        void UpdateMetaData();
        
        
        /**
        * Trigers the work unit's graphics diaplay if available 
        *
        */         
        void RunGraphics();
        
        
        /**
        * Allows the current user access to the Xhost (peculiarity of displaying BOINC graphics)
        *
        */        
        void AllowGraphics();
        
        
        /**
        * Extracts a graphics window from a work unit
        *
        */         
        void ExtractGraphics();
        
        
        /**
        * Makes extracted graphics window fullscreen
        *
        */                
        void AdjustGraphics0();       
         
        
        /**
        * Brings extracted graphics window to the foreground and focuses it
        *
        */          
        void AdjustGraphics1();


};

#endif

